<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-wms__task}">
      <wms-form v-model="dataForm" :formList="formList" :table-column="tableColumn" :advanced="advanced"
        @check-change="checkChange" @changeAdvance="changeAdvance" @getDataList="getDataList" @getReset="getReset">
      <el-form-item></el-form-item>
      </wms-form>
      <wms-table ref="wmsTable" v-model="dataForm" :page="page" :total="total" :limit="limit" :tableData="dataList"
        :table-column="column" :module-options="mixinViewModuleOptions" :dataListLoading="dataListLoading"
        :showSelection="false" @addOrUpdateHandle="addOrUpdateHandle"
        @dataListSelectionChangeHandle="dataListSelectionChangeHandle" @deleteHandle="deleteHandle"
        @pageSizeChangeHandle="pageSizeChangeHandle" @pageCurrentChangeHandle="pageCurrentChangeHandle" />
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import { formList, tableColumn } from './config'
import wmsTable from '@/components/wms-table'
import wmsForm from '@/components/wms-form'
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/wms/task/page',
        getDataListIsPage: true,
        exportURL: '/wms/task/export',
        deleteURL: '/wms/task',
        deleteIsBatch: true
      },
      dataForm: {
        taskId: ''
      },
      formList,
      tableColumn,
      column: [],
      advanced: false
    }
  },
  components: {
    wmsTable,
    wmsForm
  },
  methods: {
    retaskHandle(id) {
      if (!id && this.dataListSelections.map(item => item.taskId) <= 0) {
        return this.$message({
          message: this.$t('prompt.retask'),
          type: 'warning',
          duration: 1000
        })
      }
      this.$confirm(this.$t('prompt.info', { 'handle': this.$t('retask') }), this.$t('prompt.title'), {
        confirmButtonText: this.$t('confirm'),
        cancelButtonText: this.$t('cancel'),
        type: 'warning'
      }).then(() => {
        this.$http.post('/wms/task/retask/' + id)
          .then(({ data: res }) => {
            if (res.code !== 0) {
              return this.$message.error(res.msg)
            }
            this.$message({
              message: res.msg,
              type: 'success',
              duration: 1000,
              onClose: () => {
                this.getDataList()
              }
            })
          }).catch(() => { })

      }).catch(() => { })

    }
  }
}
</script>
